'''
Author: your name
Date: 2021-03-26 09:20:19
LastEditTime: 2021-04-02 09:50:15
LastEditors: your name
Description: In User Settings Edit
FilePath: /tinyms/tinyms-api/apps/auth/dict/model.py
'''
from app import db

class Dict(db.Model):
    __tablename__ = 'sys_dict'
    dict_pk = db.Column(db.String,primary_key=True)
    dict_code = db.Column(db.String)
    dict_name= db.Column(db.String)
    dict_type = db.Column(db.String)
    type_name = db.Column(db.String)
    dict_order = db.Column(db.String)
    dict_status = db.Column(db.String)
    dict_time = db.Column(db.String)
    dict_remark = db.Column(db.String)
    dict_level = db.Column(db.String)
    dict_parent = db.Column(db.String)

    def __repr__(self):
        return '<Dict %r>' % self.dict_pk
    

    def to_dict(items):
        lic = []
        for item in items:
            lic.append(
                {
                    'dict_pk' : item.dict_pk,
                    'dict_code' : item.dict_code,
                    'dict_name': item.dict_name,
                    'dict_type' : item.dict_type,
                    'type_name' : item.type_name,
                    'dict_order' : item.dict_order,
                    'dict_status' : item.dict_status,
                    'dict_time' : item.dict_time,
                    'dict_remark' : item.dict_remark,
                    'dict_level' : item.dict_level,
                    'dict_parent' : item.dict_parent,
                }
            )
        return lic

    def to_yj_dict(items):
        lic = []
        for item in items:
            lic.append(
                {
                    'dict_type' : item.dict_type,
                    'type_name' : item.type_name,
                }
            )
        return lic